<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
include_once ('bd/ModeloBD.php');

class ModeloTarjeta extends ModeloBD {

    private $tarcodsx;
    private $usucodsx;
    private $tarcosto;
    private $tarsaldo;

    public function __construct($tarcodsx = "", $usucodsx = "", $tarcosto = "", $tarsaldo = "") {
        $this->_oBaseDatos = CBaseDatos::get_instancia();
        $this->_oBaseDatos->conectar();
        $this->_sTabla = "tarjeta";
        $this->tarcodsx = $tarcodsx;
        $this->usucodsx = $usucodsx;
        $this->tarcosto = $tarcosto;
        $this->tarsaldo = $tarsaldo;
    }

    public function crearTarjeta() {
        $usucodsx = $this->usucodsx;
        $tarcosto = $this->tarcosto;
        $tarsaldo = $this->tarsaldo;
        $sSQL = "INSERT INTO $this->_sTabla
               (usucodsx, tarcosto,tarsaldo)
               VALUES('$usucodsx','$tarcosto','$tarsaldo')";
        $this->execute($sSQL);
    }

    public function getTarjetaByUsuario($usucodsx) {
        $arTarjeta = null;
        $sSQL = "
            SELECT *
            FROM $this->_sTabla   where usucodsx=" . $usucodsx;
        $arTarjeta = $this->query_object($sSQL);
//        var_dump($arSucursal['usuario'][0]['usucodsx']); //QUERY
//        var_dump($arSucursal[0]->usucodsx); //QUERY_OBJECT
        return $arTarjeta;
    }
        public function actualizarSaldo($usucodsx,$tarsaldo) {
        $sSQL = "UPDATE $this->_sTabla
               SET
               tarsaldo = '$tarsaldo'
               WHERE usucodsx = $usucodsx";
        $this->execute($sSQL);
    }

}

?>
